package nku.csc364.databasehelper;

import android.content.Context;
import android.database.Cursor;
import android.database.sqlite.SQLiteDatabase;

public class DataHelper1 {
	private static final String INVENTORY_TABLE_NAME = "inventory";
	private static final String ITEM_TABLE_NAME = "items";
	
	
	private Context context;
	private SQLiteDatabase db;
	private static DataHelper instance;
	
	private DataHelper1(Context context) {
	      this.context = context;
	      DatabaseHelper openHelper = new DatabaseHelper(this.context);
	      this.db = openHelper.getWritableDatabase();
	      this.db.close();
	}
	
	public Cursor getItems(String productName){
	   Cursor mCursor = this.db.query(true, ITEM_TABLE_NAME, new String[] {
				"product", "name", "status", "listprice", "unitcost", "supplier", "pict" },
				"product" + "=\"" + productName + "\"", null, null, null, null, null);
		if (mCursor != null) {
			mCursor.moveToFirst();	
		}
		return mCursor;
	}
	
	public static boolean isOpen(){
	   if(instance != null){
	   		return instance.db.isOpen();
	   }
	   else 
		   return true;
	  }
	
	   
   public static DataHelper getDataHelper1(Context context){
	   if(instance == null)
	   {
		   instance = DataHelper.getDataHelper(context);
		   if(instance == null){
			   
		   }
	   }
	   return instance;
   }
	 
}
